<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>


</head>
<!-- 比如登录时登录页面切换到注册页面就要组件切换

-->

<body>

    <div id='a'>
        <input type="button" value="注册" @click='register'>
        <input type="button" value="登录" @click='login'>
        <register v-if='appear'></register>
        <login v-else='appear'></login>
    </div>

    <template id='re'>
        <div>
            <p>注册模块</p>
        </div>
    </template>
    <template id='lo'>
        <div>
            <p>登录模块</p>
        </div>
    </template>
    <script>
        Vue.component('register', {
            template: '#re',

        })
        Vue.component('login', {
            template: '#lo',

        })
        new Vue({
            el: '#a',
            data: {
                appear: true,
            },
            methods: {
                login: function() {
                    this.appear = false;

                },
                register: function() {
                    this.appear = true;
                }
            }

        })
    </script>
</body>

</html>